home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Technology Seed / Mac Tech Seed Feb '97.toast / OpenDoc 1.2b2c1 / Implementation / Storage / Bento / UpdatCtr.cpp < prev   
Encoding:
C/C++ Source or Header  |  1997-02-13  |  4.5 KB  |  187 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        UpdatCtr.cpp
  3.  
  4.     Contains:    Implementation of ODMemContainer class.
  5.  
  6.     Owned by:    Vincent Lo
  7.  
  8.     Copyright:    © 1995 - 1996 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <5>    20.09.1996    NP        1386078: GetXXXContainer should be
  13.                                     AcquireXXXContainer in StorUtil
  14.          <4>     8/13/96    DM        1376080: TempSuppressFatalBentoError
  15.                                     spelling
  16.          <3>     5/24/96    jpa        1246074: SOM_CATCH --> SOM_TRY..SOM_ENDTRY
  17.          <2>     5/23/96    DH        1344338: Force quit of document when
  18.                                     dragging 'Bad' file or Container. Turned
  19.                                     off fatal Bento errors for Open and Create
  20.                                     container operations.
  21.  
  22. To Do:
  23.     In Progress:
  24.         
  25. */
  26.  
  27. #define ODUpdateContainer_Class_Source
  28.  
  29. #define VARIABLE_MACROS
  30.  
  31. #include <UpdatCtr.xih>
  32.  
  33. #ifndef _PLFMDEF_
  34. #include "PlfmDef.h"
  35. #endif
  36.  
  37. #ifndef SOM_ODStorageSystem_xh
  38. #include <ODStor.xh>
  39. #endif
  40.  
  41. #ifndef SOM_CMDocument_xh
  42. #include <CMDoc.xh>
  43. #endif
  44.  
  45. #ifndef _MEMHDR_
  46. #include "MemHdr.h"
  47. #endif
  48.  
  49. #ifndef _TARGTHDR_
  50. #include "TargtHdr.h"
  51. #endif
  52.  
  53. #ifndef __CM_API__
  54. #include "CMAPI.h"
  55. #endif
  56.  
  57. #ifndef _EXCEPT_
  58. #include <Except.h>
  59. #endif
  60.  
  61. #ifndef _ODNEW_
  62. #include <ODNew.h>
  63. #endif
  64.  
  65. #ifndef _STORUTIL_
  66. #include <StorUtil.h>
  67. #endif
  68.  
  69. #ifndef _PLFMFILE_
  70. #include <PlfmFile.h>
  71. #endif
  72.  
  73. #ifndef _BARRAY_
  74. #include <BArray.h>
  75. #endif
  76.  
  77. #ifndef _ODMEMORY_
  78. #include <ODMemory.h>
  79. #endif
  80.  
  81. #ifndef _BENTOSUPPRESS_
  82. #include <BentoSuppress.h>
  83. #endif
  84.  
  85. #pragma segment ODUpdateContainer
  86.  
  87. //==============================================================================
  88. // ODUpdateContainer
  89. //==============================================================================
  90.  
  91. //------------------------------------------------------------------------------
  92. // ODUpdateContainer: ~ODUpdateContainer
  93. //------------------------------------------------------------------------------
  94.  
  95. SOM_Scope void  SOMLINK ODUpdateContainersomUninit(ODUpdateContainer *somSelf)
  96. {
  97.     ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
  98.     ODUpdateContainerMethodDebug("ODUpdateContainer","somUninit");
  99.     
  100.     ODSafeReleaseObject(_fTargetDocument);
  101.     ODSafeReleaseObject(_fTargetContainer);
  102.  
  103.     ODDisposeHandle(_fHandle);
  104. }
  105.  
  106. //------------------------------------------------------------------------------
  107. // ODUpdateContainer: InitContainer
  108. //------------------------------------------------------------------------------
  109.  
  110. SOM_Scope void  SOMLINK ODUpdateContainerInitContainer(ODUpdateContainer *somSelf, Environment *ev,
  111.         ODStorageSystem* storage, ODContainerID* id)
  112. {
  113.     ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
  114.     ODUpdateContainerMethodDebug("ODUpdateContainer","InitContainer");
  115.     
  116.     SOM_TRY
  117.  
  118.     /* Moved from somInit. SOM itself sets fields to zero
  119.         _fTargetContainer = kODNULL;
  120.         _fTargetDocument = kODNULL;
  121.         _fHandle = kODNULL;
  122.     */
  123.     
  124.     ODBoolean        fileLocked = kODTrue;
  125.     PlatformFile    file;
  126.     
  127.     ODVolatile(fileLocked);
  128.     TRY
  129.         file.Specify((FSSpec*) id->_buffer);
  130.         fileLocked = file.IsLocked();
  131.         if (fileLocked == kODFalse)
  132.             file.Lock();
  133.     
  134.         {    
  135.             TempSuppressFatalBentoError temp;
  136.                 
  137.             _fTargetContainer = (ODBentoContainer*) AcquireFileContainer(ev,
  138.                             storage->GetSession(ev),     
  139.                             (FSSpec*) id->_buffer);
  140.         }
  141.         _fTargetDocument = (CMDocument*) _fTargetContainer->AcquireDocument(ev, kODDefaultDocument);
  142.         if (fileLocked == kODFalse)
  143.             file.Unlock();
  144.             
  145.     CATCH_ALL
  146.     
  147.         if (fileLocked == kODFalse)
  148.             file.Unlock();
  149.  
  150.         RERAISE;
  151.         
  152.     ENDTRY
  153.  
  154.     _fHandle = ODNewHandle(0);
  155.     
  156.     ODByteArray* ba = CreateByteArray(&_fHandle, sizeof(ODHandle));    
  157.     parent_InitContainer(somSelf, ev, storage, ba);
  158.     DisposeByteArray(ba);
  159.  
  160.     SOM_CATCH_ALL
  161.     SOM_ENDTRY
  162. }
  163.  
  164. //------------------------------------------------------------------------------
  165. // ODUpdateContainer: GetTargetFileContainer
  166. //------------------------------------------------------------------------------
  167.  
  168. SOM_Scope ODBentoContainer*  SOMLINK ODUpdateContainerGetTargetContainer(ODUpdateContainer *somSelf, Environment *ev)
  169. {
  170.     ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
  171.     ODUpdateContainerMethodDebug("ODUpdateContainer","GetTargetContainer");
  172.  
  173.     return _fTargetContainer;
  174. }
  175.  
  176. //------------------------------------------------------------------------------
  177. // ODUpdateContainer: GetTargetDocument
  178. //------------------------------------------------------------------------------
  179.  
  180. SOM_Scope CMDocument*  SOMLINK ODUpdateContainerGetTargetDocument(ODUpdateContainer *somSelf, Environment *ev)
  181. {
  182.     ODUpdateContainerData *somThis = ODUpdateContainerGetData(somSelf);
  183.     ODUpdateContainerMethodDebug("ODUpdateContainer","GetTargetDocument");
  184.  
  185.     return _fTargetDocument;
  186. }
  187.